package designmodel.creator.factorymethod;

import designmodel.creator.factorymethod.impl.ClassA;
import designmodel.creator.factorymethod.impl.ClassB;
import designmodel.creator.factorymethod.impl.ClassC;

/**
 * 工厂方法的工厂类
 */
public class Factory {
    // 根据入参类型自动生成对应的类
    public ICommen getService(int type) {
        switch (type) {
            case 1:
                return new ClassA();
            case 2:
                return new ClassB();
            case 3:
                return new ClassC();
            default:
                return null;
        }
    }
}
